#pragma once

#include "afxwin.h"
#include <afxtempl.h>
#include "WeatherAreaDlg.h"

#ifdef _DEBUG
#include "Unicode_Debug/nateon.tlh"
#else // elif(_DEBUG)
#include "Unicode_Release/nateon.tlh"
#endif // _DEBUG



// CWeatherMainDlg dialog

class CWeatherMainDlg : public CDialog
{
	DECLARE_DYNAMIC(CWeatherMainDlg)

public:
	CWeatherMainDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CWeatherMainDlg();

    virtual BOOL Create(CWnd* pParentWnd = NULL);
    void    SetDllPath (LPCTSTR strPath) { m_strDllPath = strPath; };

// Dialog Data
	enum { IDD = IDD_DIALOG_WEATHERMAIN };

protected:
    virtual BOOL OnInitDialog();
    virtual void PostNcDestroy();
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    afx_msg void OnDestroy();
    afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
    afx_msg void OnPaint();
    afx_msg void OnTimer(UINT_PTR nIDEvent);
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg LONG OnMouseHover(WPARAM wParam, LPARAM lParam);
    afx_msg LONG OnMouseLeave(WPARAM wParam, LPARAM lParam);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

	DECLARE_MESSAGE_MAP()

private:
    BOOL    InitializeNateOn();
    void    UninitNateOn    ();
    BOOL    RetrieveWeather ();
    BOOL    ParseWeatherInfo();
    void    DrawWeather     (CDC* pDC);
    BOOL    RetrieveInfo    ();
    void    RollingWeather  ();
    void    SortingWeather  (CStringArray& astrWeather);
    void    ReadOption      ();
    void    WriteOption     ();

    int           m_nCount;
    int           m_nIndex;
    CString       m_strDllPath;
    CString       m_strXmlPath;
    CString       m_strYear;
    CString       m_strMonth;
    CString       m_strDay;
    CString       m_strHour;
    CString       m_strDateTime;
    CString       m_strWeather;
    CString       m_strArea;
    CString       m_strIconPath;
    CRect         m_rcWindow;
    RectF         m_rcDrawText;
    Font          m_fontText;
    SolidBrush    m_brushBack;
    SolidBrush    m_brushText;
    Image*        m_pImgBack;
    Image*        m_pImgIcon;
    CStringArray  m_astrArea;
    WEATHERINFO   m_weatherInfo;
    volatile BOOL m_bMouseOver;

    CArray<WEATHERINFO, WEATHERINFO> m_arrWeatherInfo;
    CMapStringToString               m_mapWeatherInfo;
    CWeatherAreaDlg                  m_dlgWeatherArea;
};
